using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;

using DevComponents.DotNetBar;

namespace Pg.BioMedics.RatObserver.Gui.Utils
{
    internal static class Logger
    {
        #region Constants

        private const string Source = "RatObserver.Gui";

        #endregion

        #region Static methods

        internal static void WriteError(Exception ex)
        {
            try
            {
                MessageBoxEx.Show(String.Format("Error occured : {0}", ex.Message),
                                  "Application error",
                                  MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);

                EventLog.WriteEntry(Source, 
                                    String.Format("{0} \n {1} \n {2}", ex.Message, ex.StackTrace, ex.TargetSite), 
                                    EventLogEntryType.Error); 
            }
            catch {}
        }

        internal static void WriteInfo(string message)
        {
            try
            {
                MessageBoxEx.Show(message,
                                  "Info",
                                  MessageBoxButtons.OK,
                                  MessageBoxIcon.Information);

                EventLog.WriteEntry(Source, message, EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
        }

        #endregion
    }
}
